﻿using BGYXControlLibrary.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace BGYXControlLibrary
{
    public class BGYX_Alert : ContentControl
    {
        public bool IsLoading
        {
            get { return (bool)GetValue(IsLoadingProperty); }
            set { SetValue(IsLoadingProperty, value); }
        }

        public static readonly DependencyProperty IsLoadingProperty = DependencyProperty.Register(
          "IsLoading",
          typeof(bool),
          typeof(BGYX_Alert),
          new FrameworkPropertyMetadata(false, new PropertyChangedCallback(ReferenControlsCallback))
        );

        public Icons LoadType
        {
            get { return (Icons)GetValue(LoadTypeProperty); }
            set { SetValue(LoadTypeProperty, value); }
        }

        public static readonly DependencyProperty LoadTypeProperty = DependencyProperty.Register(
          "LoadType",
          typeof(Icons),
          typeof(BGYX_Alert),
          new FrameworkPropertyMetadata(Icons.FONTAWESOME_SOLID_0, new PropertyChangedCallback(ReferenControlsCallback))
        );

        public RotateDirection Direction
        {
            get { return (RotateDirection)GetValue(DirectionProperty); }
            set { SetValue(DirectionProperty, value); }
        }

        public static readonly DependencyProperty DirectionProperty = DependencyProperty.Register(
          "Direction",
          typeof(RotateDirection),
          typeof(BGYX_Alert),
          new FrameworkPropertyMetadata(RotateDirection.Right, new PropertyChangedCallback(ReferenControlsCallback))
        );

        public double ContentWidth
        {
            get { return (double)GetValue(ContentWidthProperty); }
            set { SetValue(ContentWidthProperty, value); }
        }

        public static readonly DependencyProperty ContentWidthProperty = DependencyProperty.Register(
          "ContentWidth",
          typeof(double),
          typeof(BGYX_Alert),
          new FrameworkPropertyMetadata(500d, new PropertyChangedCallback(ReferenControlsCallback))
        );

        public double ContentHeight
        {
            get { return (double)GetValue(ContentHeightProperty); }
            set { SetValue(ContentHeightProperty, value); }
        }

        public static readonly DependencyProperty ContentHeightProperty = DependencyProperty.Register(
          "ContentHeight",
          typeof(double),
          typeof(BGYX_Alert),
          new FrameworkPropertyMetadata(300d, new PropertyChangedCallback(ReferenControlsCallback))
        );

        private static void ReferenControlsCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            
        }


        static BGYX_Alert()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(BGYX_Alert), new FrameworkPropertyMetadata(typeof(BGYX_Alert)));
        }

        public BGYX_Alert()
        {

        }


        public static BGYX_Icon icon = null;

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //调试动画是否一直运行
            //icon = this.Template.FindName("Load", this) as BGYX_Icon;
            //new Thread(() =>
            //{
            //    while (true)
            //    {
            //        Thread.Sleep(300);
            //        Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            //        {
            //            Console.WriteLine((icon.RenderTransform as RotateTransform).Angle);
            //        }));
            //    }
            //})
            //{
            //    IsBackground = true
            //}.Start();
        }
    }
}
